package com.codeplay.repository;

import com.codeplay.entity.Permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.Set;

@Repository
public interface PermissionRepository extends JpaRepository<Permission, Long> {
    Optional<Permission> findByName(String name);
    Set<Permission> findByNameIn(Set<String> names);
    boolean existsByName(String name);
    List<Permission> findByCategory(String category);
    
    @Query("SELECT DISTINCT p.category FROM Permission p WHERE p.category IS NOT NULL")
    List<String> findAllCategories();
} 